<?php
/**
 * Created by PhpStorm.
 * User: sl
 * Date: 17-6-23
 * Time: 下午1:01
 */

namespace ActionsHttp;

use Data\Tree_question;
use Data\Tree_question_DAO;

class QuestionAdd extends BaseActionHttp
{
    public function doAction() {
        parent::doAction();
        $customer_id_random_str = $this->data[CUSTOMER_ID];
        $customer_id = substr($customer_id_random_str,10);
        // 检测登陆是否过期
        if (!($this->checkSession($customer_id))) {
            return;
        }

        $question_content = $this->data[QUESTION_CONTENT];
        $contact_number = $this->data[CONTACT_NUMBER];

        if (!$question_content) {
            return $this->SendErrMsg("参数错误，问题内容不能为空");
        }



        $question_record = new Tree_question(array());
        $question_record->setCUSTOMER_ID($customer_id);
        $question_record->setQUESTION_CONTENT($question_content);
        $question_record->setCONTACT_NUMBER($contact_number);
        Tree_question_DAO::insert($question_record);

        // 返回数据
        $this->ResponseDataToCurrentClient();
    }
}